﻿<UserControl x:Class="FileSystemExplorerUserControl.FileSystemExplorer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:FileSystemExplorerUserControl" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    
    <UserControl.Resources>

    </UserControl.Resources>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.80*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid Grid.Column="0" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <TreeView 
                Name="treeViewDirectories" 
                Grid.Column="0" 
                Grid.Row="0" 
                HorizontalAlignment="Stretch" 
                Margin="5,5,0,5" 
                VerticalAlignment="Stretch" 
                Width="Auto" 
                Height="Auto" 
                TreeViewItem.Selected="treeViewDirectories_Selected" 
                TreeViewItem.Expanded="treeViewDirectories_Expanded">

                <TreeView.Resources>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="HeaderTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Image 
                                            Name="img"  
                                            Width="20" 
                                            Height="20" 
                                            Stretch="Fill" 
                                            Source="{Binding 
                                            RelativeSource={RelativeSource 
                                            Mode=FindAncestor, 
                                            AncestorType={x:Type TreeViewItem}}, 
                                            Path=Header, 
                                            Converter={x:Static local:HeaderToImageConverter.Instance}}" />
                                        <TextBlock Text="{Binding}" Margin="5,0" />
                                    </StackPanel>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </TreeView.Resources>
            </TreeView>
        </Grid>

        <GridSplitter 
            Name="gridSplitter" 
            Grid.Column="1" 
            HorizontalAlignment="Left" 
            Margin="5,5,5,5" 
            VerticalAlignment="Stretch" 
            ResizeBehavior="PreviousAndNext" 
            Width="5" 
            Background="#FFD5DFE5"/>

        <Grid Grid.Column="2" Grid.Row="0">
            <ListBox 
                Name="listBoxFiles" 
                Height="Auto" 
                HorizontalAlignment="Stretch" 
                Margin="0,5,5,5" 
                VerticalAlignment="Stretch" 
                Width="Auto" 
                DragEnter="listBoxFiles_DragEnter" 
                Drop="listBoxFiles_Drop" 
                SelectionChanged="listBoxFiles_SelectionChanged" AllowDrop="True" />
        </Grid>
        
    </Grid>
</UserControl>
